ostbuild: Have resolve use git-mirror rather than duplicating code
authorColin Walters <walters@verbum.org>
Sat, 26 May 2012 16:10:51 +0000 (12:10 -0400)
committerColin Walters <walters@verbum.org>
Sat, 26 May 2012 16:10:51 +0000 (12:10 -0400)
This also brings us back to a sensible world of:

ostbuild resolve --fetch

Doing both fetch *and* writing out the updated revisions.

src/ostbuild/pyostbuild/builtin_resolve.py

index a5160f963f74a19e073c781b2161d6c591540c0d..d97150c5a791ca6d576e78a615c6a5654c989258 100755 (executable)
@@ -77,7 +77,7 @@ class OstbuildResolve(builtins.Builtin):
         parser = argparse.ArgumentParser(description=self.short_description)
         parser.add_argument('--manifest', required=True)
         parser.add_argument('--fetch-patches', action='store_true')
-        parser.add_argument('components', nargs='*')
+        parser.add_argument('--fetch', action='store_true')
 
         args = parser.parse_args(argv)
         self.args = args
@@ -90,25 +90,35 @@ class OstbuildResolve(builtins.Builtin):
         components = map(self._resolve_component_meta, self.snapshot['components'])
         self.snapshot['components'] = components
 
+        unique_component_names = set()
+        for component in components:
+            name = component['name']
+
+            if name in unique_component_names:
+                fatal("Duplicate component name '%s'" % (name, ))
+            unique_component_names.add(name)
+
         global_patches_meta = self._resolve_component_meta(self.snapshot['patches'])
         self.snapshot['patches'] = global_patches_meta
         (keytype, uri) = vcs.parse_src_key(global_patches_meta['src'])
         mirrordir = vcs.ensure_vcs_mirror(self.mirrordir, keytype, uri, global_patches_meta['branch'])
         if args.fetch_patches:
             run_sync(['git', 'fetch'], cwd=mirrordir, log_initiation=False)
-        revision = buildutil.get_git_version_describe(mirrordir, global_patches_meta['branch'])
-        global_patches_meta['revision'] = revision
 
-        unique_component_names = set()
-        for component in components:
-            (keytype, uri) = vcs.parse_src_key(component['src'])
-            name = component['name']
+        git_mirror_args = ['ostbuild', 'git-mirror']
+        if args.fetch:
+            git_mirror_args.append('--fetch')
+        run_sync(git_mirror_args)
 
-            if name in unique_component_names:
-                fatal("Duplicate component name '%s'" % (name, ))
-            unique_component_names.add(name)
+        patch_revision = buildutil.get_git_version_describe(mirrordir, global_patches_meta['branch'])
+        global_patches_meta['revision'] = patch_revision
 
-            branch_or_tag = component.get('branch') or component.get('tag')
+        for component in components:
+            src = component['src']
+            (keytype, uri) = vcs.parse_src_key(src)
+            branch = component.get('branch')
+            tag = component.get('tag')
+            branch_or_tag = branch or tag
             mirrordir = vcs.ensure_vcs_mirror(self.mirrordir, keytype, uri, branch_or_tag)
             revision = buildutil.get_git_version_describe(mirrordir, branch_or_tag)
             component['revision'] = revision